--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_ibuki_suika = General:new(extension, "hy_ibuki_suika", "ten_k", 4, 4, General.Female)
    local oni_fog = fk.CreateSkill {
        name = "oni_fog",
    }
    oni_fog:addEffect(fk.AfterCardsMove, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player, data)
            if not player:hasSkill(oni_fog.name) then
                return false
            end
            local records = player:getMark("@$oni_fog")
            local current = {}
            for _, move in ipairs(data) do
                if move.from and move.from == player then
                    for _, info in ipairs(move.moveInfo) do
                        if info.fromArea == Card.PlayerEquip or info.fromArea == Card.PlayerHand then
                            table.insertIfNeed(current, Fk:getCardById(info.cardId).trueName)
                        end
                    end
                end
            end
            if records == 0 then
                event:setCostData(self, current)
                return #current > 0
            else
                table.insertTableIfNeed(current, records)
                event:setCostData(self, current)
                return #event:getCostData(self) > #records
            end
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:setPlayerMark(player, "@$oni_fog", event:getCostData(self))
        end,
    })
    local extract = fk.CreateSkill {
        name = "extract",
    }
    extract:addEffect("viewas", {
        mute_card = false,
        anim_type = "defensive",
        pattern = ".",
        card_filter = Util.FalseFunc,
        interaction = function(self, player)
            local trueNames = player:getMark("@$oni_fog")
            local results = {}
            for _, cardId in ipairs(Fk:getAllCardIds()) do
                local card = Fk:getCardById(cardId)
                if card.type == Card.TypeBasic or card:isCommonTrick() then
                    if not table.contains(results, card.name) and table.contains(trueNames, card.trueName) then
                        local c = Fk:cloneCard(card.name)
                        c.skillName = "extract"
                        if Fk.currentResponsePattern == nil and c.skill:canUse(player, c) then
                            table.insertIfNeed(results, card.name)
                        elseif Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c) then
                            table.insertIfNeed(results, card.name)
                        end
                    end
                end
            end
            if #results == 0 then
                return
            end
            return UI.ComboBox { choices = results }
        end,
        prompt = function(self, selected, selected_cards)
            return "extract_prompt"
        end,
        view_as = function(self, player, cards)
            if not self.interaction.data then
                return
            end
            local card = Fk:cloneCard(self.interaction.data)
            table.insertIfNeed(card.skillNames, extract.name)
            return card
        end,
        enabled_at_play = function(self, player)
            if player:getMark("@$oni_fog") == 0 then
                return false
            end
            return player:getMark("@extract_record-turn") < #player:getMark("@$oni_fog")
        end,
        enabled_at_response = function(self, player, response)
            if player:getMark("@$oni_fog") == 0 then
                return false
            end
            return player:getMark("@extract_record-turn") < #player:getMark("@$oni_fog") and table.any(player:getTableMark("@$oni_fog"), function(name)
                return Fk.currentResponsePattern and Fk.currentResponsePattern:match(name)
            end)
        end,
        enabled_at_nullification = function(self, player, data)
            if player:getMark("@$oni_fog") == 0 then
                return false
            end
            return player:getMark("@extract_record-turn") < #player:getMark("@$oni_fog") and table.any(player:getTableMark("@$oni_fog"), function(name)
                return Fk.currentResponsePattern and Fk.currentResponsePattern:match(name)
            end)
        end,
    })
    extract:addEffect("targetmod", {
        bypass_times = function(self, player, skill, scope, card, to)
            return table.contains(card.skillNames, "extract")
        end
    })
    extract:addEffect(fk.PreCardUse, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(extract.name) and table.contains(data.card.skillNames, "extract")
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            room:addPlayerMark(player, "@extract_record-turn", 1)
            room:setPlayerMark(player, "@$oni_fog", 0)
        end,
    })
    extract:addEffect(fk.PreCardRespond, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(extract.name) and table.contains(data.card.skillNames, "extract")
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            room:addPlayerMark(player, "@extract_record-turn", 1)
            room:setPlayerMark(player, "@$oni_fog", 0)
        end,
    })
    extension:loadSkillSkels { oni_fog, extract }
    hy_ibuki_suika:addSkill("oni_fog")
    hy_ibuki_suika:addSkill("extract")
    Fk:loadTranslationTable {
        ["hy_ibuki_suika"] = "伊吹萃香",
        ["#hy_ibuki_suika"] = "密度的界限",
        ["illustrator:hy_ibuki_suika"] = "Ħareumeria",
        ["designer:hy_ibuki_suika"] = "黑曜人形",
        ["cv:hy_ibuki_suika"] = "",

        ["oni_fog"] = "鬼雾",
        [":oni_fog"] = "在你失去一张牌后，若此牌未被记录，你记录此牌的牌名。",
        ["@$oni_fog"] = "鬼雾",

        ["extract"] = "萃集",
        [":extract"] = "若“鬼雾”的记录数大于X，你可以视为使用或打出一张被“鬼雾”记录的基本牌或普通锦囊牌（无次数限制）并清除“鬼雾”的所有记录（X为本回合你发动过“萃集”的次数）。",
        ["extract_prompt"] = "萃集：你可以视为使用或打出记录中的基本牌或普通锦囊牌",
        ["@extract_record-turn"] = "萃集",
    }
end
